﻿using System;
using System.ComponentModel;
using System.Drawing;

namespace HML
{
    /// <summary>
    /// ImageSlide选项
    /// </summary>
    [TypeConverter(typeof(PropertyOrderConverter))]
    public class ImageSlideItem
    {
        #region 属性

        private string text = null;
        /// <summary>
        /// 图片标题文本
        /// </summary>
        [Description("图片标题文本")]
        [PropertyOrder(-198)]
        [DefaultValue("")]
        public string Text
        {
            get { return this.text; }
            set
            {
                if (this.text == value)
                    return;

                this.text = value;
                this.Invalidate();
            }
        }

        private Image image = null;
        /// <summary>
        /// 图片
        /// </summary>
        [Description("图片")]
        [PropertyOrder(-196)]
        [DefaultValue(null)]
        [RefreshProperties(RefreshProperties.Repaint)]
        public Image Image
        {
            get { return this.image; }
            set
            {
                if (this.image == value)
                    return;

                this.image = value;
                this.Invalidate();
            }
        }

        private object tag = null;
        /// <summary>
        /// 自定义数据
        /// </summary>
        [Description("自定义数据")]
        [PropertyOrder(-188)]
        [DefaultValue(null)]
        [Bindable(true)]
        [Localizable(false)]
        [TypeConverter(typeof(StringConverter))]
        public virtual object Tag
        {
            get { return this.tag; }
            set { this.tag = value; }
        }

        private ImageSlide owner = null;
        /// <summary>
        /// 选项所属的控件
        /// </summary>
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public ImageSlide Owner
        {
            get { return this.owner; }
            internal protected set { this.owner = value; }
        }

        #endregion

        #region 私有方法

        /// <summary>
        /// 刷新控件
        /// </summary>
        private void Invalidate()
        {
            if (this.owner != null && this.owner.IsInImageFrame(this))
            {
                this.owner.Invalidate();
            }
        }

        #endregion

    }

}
